﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

using PhoneApp1.Entity;
using System.IO.IsolatedStorage;
using System.Collections;
using System.Data;
using System.Collections;



namespace PhoneApp1
{
    public partial class pvLogin : PhoneApplicationPage
    {
        public pvLogin()
        {
            InitializeComponent();
        }
      
        private void btnIngresar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                WCF_LESO.Usuario user = new WCF_LESO.Usuario();
                user.Usuario_Usuario = txtUser.Text.Trim().ToUpper();
                user.Password_Usuario = txtPass.Password.Trim().ToUpper();

                WCF_LESO.ServicePhoneClient proxy = new WCF_LESO.ServicePhoneClient();
                proxy.IngresarAppCompleted += new EventHandler<WCF_LESO.IngresarAppCompletedEventArgs>(proxy_IngresarAppCompleted);
                proxy.IngresarAppAsync(user);
            }
            catch { }

        }

        protected void proxy_IngresarAppCompleted(object sender, WCF_LESO.IngresarAppCompletedEventArgs e) {

            if (e.Result == true)
            {
                txtUser.Text = "";
                txtPass.Password = "";
                NavigationService.Navigate(new Uri("/pvMenu.xaml", UriKind.RelativeOrAbsolute));
            }
            else {
                MessageBox.Show("Datos incorrectos");
            }
        }


    }
}